package com.qsmx.qingqiuticket.app.entity;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;

import java.io.Serializable;

public class GoodsListEntity implements Parcelable {

    private int quantity;
    private String goodsId;
    private String productName;
    private double salePrice;
    private String productPic;
    private String goodsQrCode;

    public GoodsListEntity() {

    }

    public GoodsListEntity(Parcel in) {
        quantity = in.readInt();
        goodsId = in.readString();
        productName = in.readString();
        salePrice = in.readDouble();
        productPic = in.readString();
        goodsQrCode = in.readString();
    }

    public static final Creator<GoodsListEntity> CREATOR = new Creator<GoodsListEntity>() {
        @Override
        public GoodsListEntity createFromParcel(Parcel in) {
            return new GoodsListEntity(in);
        }

        @Override
        public GoodsListEntity[] newArray(int size) {
            return new GoodsListEntity[size];
        }
    };

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public double getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(double salePrice) {
        this.salePrice = salePrice;
    }

    public String getProductPic() {
        return productPic;
    }

    public void setProductPic(String productPic) {
        this.productPic = productPic;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public String getGoodsQrCode() {
        return goodsQrCode;
    }

    public void setGoodsQrCode(String goodsQrCode) {
        this.goodsQrCode = goodsQrCode;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeInt(quantity);
        parcel.writeString(goodsId);
        parcel.writeString(productName);
        parcel.writeDouble(salePrice);
        parcel.writeString(productPic);
        parcel.writeString(goodsQrCode);
    }

    public JSONObject toJSONObject() {
        JSONObject json = new JSONObject();

        try {
            json.put("id", goodsId);
            json.put("perSalePrice", salePrice);
            json.put("quantity", quantity);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return json;
    }
}
